new Vue({
 el:'#z_head',
 data:{
   navList:[],
   key:''
 },
 methods:{
   readFile(){
     this.$http.get('./public/source/data.json').then(response =>{
       let res = response.body;
       if(res){
         this.navList = res.navs;
       }
     },response=>{
       console.log('请求数据失败！');  
     });
   },
   readIndex(){   
     this.navList[5].check = true;
   },
   toSearch(){
     if(this.key!==''){
       window.open(`/search?key=${this.key}`,'_blank');
     }   
    }
  
 },

 created(){
   $("#headUl").html(`
   <a :href="item.url" v-for="(item,index) in navList" :key="item.title" >
      <li :class="item.check ? 'active': ''">{{ item.title }}</li>
   </a>`);
   this.readFile();  
 },
 updated(){   
  this.readIndex();
 },
 
 
});